<template>
  <div id="yg_tags">
    <h3 class="title">标签集</h3>
    <ul class="list">
      <li class="item" v-for="item in tagsList" :key="item?.id">
        <router-link :to="`/tag/${item?.id}`" :style="{ backgroundColor: item?.backgroundColor }">
          {{ item?.title }}
        </router-link>
      </li>
    </ul>
  </div>
</template>

<script>
import { randomColor } from "@/utils/YgHooks";
import { mapState } from "vuex";
export default {
  name: "YgTags",
  computed: {
    ...mapState('Tag', ['tagsList'])
  },
  methods: {
    randomColor(index) {
      return randomColor(index);
    },
  },
};
</script>

<style lang="scss" scoped>
#yg_tags {
  display: flex;
  flex-direction: column;
  border-radius: 4px;
  overflow: hidden;
  & > .title {
    display: flex;
    flex-direction: row;
    align-items: center;
    margin: 0;
    padding: 0 12px;
    height: 40px;
    background-color: #eaeaea;
    font-size: 14px;
    font-weight: 500;
    color: #3d3d3d;
    user-select: none;
    cursor: default;
  }
  & > .list {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 9px !important;
    background-color: #fff;
    & > .item {
      display: flex;
      flex-direction: row;
      & > a {
        margin: 3px;
        padding: 4px 12px;
        border-radius: 4px;
        font-size: 12px;
        font-weight: 400;
        color: #fff;
        line-height: 12px;
        user-select: none;
      }
    }
  }
}
</style>
